package com.spa.domain.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.domain.entity.CouponExchange;
import com.spa.infrastructure.mapper.CouponMapperStruct;
import com.spa.infrastructure.repository.condition.CouponExchangeCondition;
import com.spa.infrastructure.repository.po.CouponExchangePO;
import com.spa.infrastructure.repository.service.CouponExchangeRepositoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 团购券  domain
 *
 */
@Service
public class CouponExchangeService {

    @Resource
    private CouponExchangeRepositoryService couponExchangeRepositoryService;

    public int insertCoupon(CouponExchangePO po) {
        return couponExchangeRepositoryService.insert(po);
    }

    public Page<CouponExchange> page(CouponExchangeCondition condition) {
        return CouponMapperStruct.INSTANCE.po2CouponExchange4Page(couponExchangeRepositoryService.page(condition));
    }

    public List<CouponExchange> list(CouponExchangeCondition condition) {
        return CouponMapperStruct.INSTANCE.po2CouponExchange4List(couponExchangeRepositoryService.listAll(condition));
    }

    public long countByCondition(CouponExchangeCondition condition) {
        return couponExchangeRepositoryService.countByCondition(condition);
    }
}
